<?php

/**
 * users table
 *
 * @author     Mon Zafra <monzee at gmail>
 * @copyright  (c)2009 Mon Zafra
 * @category   Mz
 * @package    modules
 * @subpackage admin
 * @license    http://mz-project.googlecode.com/svn/trunk/LICENSE    MIT License
 * @version    SVN: $Id: User.php 29 2009-05-14 15:35:03Z monzee $
 */
class Admin_Model_DbTable_User extends Zend_Db_Table_Abstract
{
    protected $_name = 'users';
    public $userRoleTable = 'user_roles';

    public function getRoles($user)
    {
        $userId = $user['id'];

        $sel = $this->select()->setIntegrityCheck(false)
                    ->from(array('u' => $this->_name), array())
                    ->join($this->userRoleTable,
                           'user_id = u.id',
                           array('id' => 'role_id'))
                    ->where('u.id = ?', $userId);

        return $this->fetchAll($sel);
    }

    static public function __callStatic($method, $args)
    {
        $self = new self();
        if (method_exists($method, $self)) {
            return call_user_func_array(array($self, $method), $args);
        }
        throw new BadMethodCallException('No such method (' . $method . ').');
    }

}